#被动技能【咒梦】
execute as @a[tag=mengyan,scores={skStone_sword0=1..}] at @s run function nw:yingxiong/2yingxiong/10mengyan/skill/0zhoumeng
scoreboard players reset @a[tag=mengyan,scores={skStone_sword0=1..}] skStone_sword0
#被动技能 【堕落之梦】
effect clear @a[scores={mengyan5=2..}] speed
effect clear @a[scores={mengyan5=4..}] strength

#主动技能【入梦/碎梦】
execute as @a[tag=mengyan,scores={skEgg=1..}] at @s run function nw:yingxiong/2yingxiong/10mengyan/skill/1rumeng
#主动技能【入梦/碎梦】CD
execute as @a[tag=mengyan,scores={skCDEgg=..0}] run function nw:yingxiong/2yingxiong/10mengyan/skill/1rumeng_cd

#主动技能【遁入梦境】
execute as @a[tag=mengyan,scores={skPearl=1}] at @s run function nw:yingxiong/2yingxiong/10mengyan/skill/2dunru
#主动技能【遁入梦境】二段：触发
execute as @a[tag=mengyan,scores={skPearl=2}] at @s unless block ~ ~-0.5 ~ air run function nw:yingxiong/2yingxiong/10mengyan/skill/2dunru2
#主动技能【遁入梦境】CD
execute as @a[tag=mengyan,scores={skCDPearl=..0}] run function nw:yingxiong/2yingxiong/10mengyan/skill/2dunru_cd

#主动技能【梦魇缠绕】
execute as @a[tag=mengyan,scores={skEXBottle=1..}] at @s run function nw:yingxiong/2yingxiong/10mengyan/skill/3mengyan
#主动技能【梦魇缠绕】CD
execute as @a[tag=mengyan,scores={skCDEXBottle=..0}] run function nw:yingxiong/2yingxiong/10mengyan/skill/3mengyan_cd
#主动技能【遁入梦境】效果
execute as @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] at @s run particle large_smoke ~ ~0.5 ~ 0.1 0.2 0.1 0.1 2 normal @a

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run scoreboard players set @a[distance=0.1..4,scores={mengyan5=5,EFDizzy=0},gamemode=!spectator] EFDizzy 30
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run scoreboard players remove @a[distance=0.1..4,scores={mengyan5=5,EFDizzy=..-1},gamemode=!spectator] EFDizzy 30
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=5},gamemode=!spectator] wither 5 1
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=5},gamemode=!spectator] instant_damage 1 1

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run scoreboard players set @a[distance=0.1..4,gamemode=!spectator,scores={mengyan5=4,EFLock=0}] EFLock 20
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run scoreboard players remove @a[distance=0.1..4,gamemode=!spectator,scores={mengyan5=4,EFLock=..-1}] EFLock 20
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=4},gamemode=!spectator] wither 5 1
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=4},gamemode=!spectator] instant_damage 1 0

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=3},gamemode=!spectator] slowness 3 1
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=3},gamemode=!spectator] weakness 3 0
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=3},gamemode=!spectator] wither 4 2

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=2},gamemode=!spectator] slowness 3 0
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=2},gamemode=!spectator] weakness 3 0
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=2},gamemode=!spectator] wither 3 2

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=1},gamemode=!spectator] weakness 3 0
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run effect give @a[distance=0.1..4,scores={mengyan5=1},gamemode=!spectator] wither 3 1

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] as @p[distance=0.1..6,nbt={DeathTime:1s}] run title @s title [{"text":"梦魇覆盖","color":"dark_red","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] as @p[distance=0.1..6,nbt={DeathTime:1s}] run title @s subtitle [{"text":"噩梦缠绕于你，我将终结你","color":"green","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":" —梦魇","color":"black","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]

execute at @a[tag=mengyan,nbt={ActiveEffects:[{Id:18b,Amplifier:9b}]}] run scoreboard players set @a[distance=0.1..4,scores={mengyan5=1..}] mengyan5 0


#主动技能【梦魇缠绕】效果1>每秒增加1噩梦
execute as @e[type=armor_stand,tag=mengyan,scores={skCDKe=20..}] at @s run scoreboard players add @a[tag=!mengyan,distance=0..4.5,scores={mengyan5=..4},gamemode=!spectator] mengyan5 1
execute as @e[type=armor_stand,tag=mengyan,scores={skCDKe=20..}] run scoreboard players reset @s skCDKe
#主动技能【梦魇缠绕】效果2>自身位于法阵内吸取最中心敌人血量
execute at @e[type=armor_stand,tag=mengyan] run effect give @p[distance=0..4.5,tag=!mengyan,gamemode=!spectator] hunger 4 9 true
execute at @e[type=armor_stand,tag=mengyan] if entity @a[distance=0..4.5,tag=!mengyan,nbt={ActiveEffects:[{Id:17b,Amplifier:9b}]}] run effect give @a[distance=0..4.5,tag=mengyan,gamemode=!spectator] regeneration 2 1 true

#主动技能【梦魇缠绕】显示范围
execute at @e[type=armor_stand,tag=mengyan] run particle smoke ~ ~0.2 ~ 1.6 0.1 1.6 0.01 10 normal @a
execute as @e[type=armor_stand,tag=mengyan] at @s run tp @s ~ ~ ~ ~6 ~
execute as @e[type=armor_stand,tag=mengyan] at @s rotated ~ 0 positioned ^ ^0.1 ^4.5 run particle large_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 1 normal @a
execute as @e[type=armor_stand,tag=mengyan] at @s run tp @s ~ ~ ~ ~6 ~
execute as @e[type=armor_stand,tag=mengyan] at @s rotated ~ 0 positioned ^ ^0.1 ^4.5 run particle large_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 1 normal @a
execute as @e[type=armor_stand,tag=mengyan] at @s run tp @s ~ ~ ~ ~6 ~
execute as @e[type=armor_stand,tag=mengyan] at @s rotated ~ 0 positioned ^ ^0.1 ^4.5 run particle large_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 1 normal @a
execute as @e[type=armor_stand,tag=mengyan] at @s run tp @s ~ ~ ~ ~6 ~
execute as @e[type=armor_stand,tag=mengyan] at @s rotated ~ 0 positioned ^ ^0.1 ^4.5 run particle large_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 1 normal @a
execute as @e[type=armor_stand,tag=mengyan] at @s run tp @s ~ ~ ~ ~6 ~
execute as @e[type=armor_stand,tag=mengyan] at @s rotated ~ 0 positioned ^ ^0.1 ^4.5 run particle large_smoke ~ ~ ~ 0.1 0.1 0.1 0.01 1 normal @a


kill @e[type=armor_stand,tag=mengyan,scores={skCDEntity=5..}]

execute as @a[tag=mengyan] run title @s actionbar [{"text":"入梦/碎梦","color":"dark_red","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"正在冷却：","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"score":{"objective":"skCDEgg","name":"@s"},"color":"aqua","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"s","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":" 遁入梦境","color":"dark_red","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"正在冷却：","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"score":{"objective":"skCDPearl","name":"@s"},"color":"aqua","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"s","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":" 梦魇缠绕","color":"dark_red","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"正在冷却：","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"score":{"objective":"skCDEXBottle","name":"@s"},"color":"aqua","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"s","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
